package com.ygsoft.example.facebook;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ApiIntegrationController {
	
	private static Logger log = Logger.getLogger(ApiIntegrationController.class);
	
	@RequestMapping("/loginIntro.do")
	public ModelAndView loginIntro() {
		log.info("Request FB from remote client ..");
		
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("message", "Spring 3 MVC Hello World" + System.currentTimeMillis());
		modelAndView.setViewName("fbLogin");
		return modelAndView;
	}
	
	@RequestMapping("/channel.do")
	@ResponseBody
	public String channel(HttpServletResponse response){
		log.info("channel request from FB");
		response.setContentType("text/plain");
	    response.setCharacterEncoding("UTF-8");
	    return "<script src=\"//connect.facebook.net/en_US/all.js\"></script>";
	}
}
